package Day4_sampleCodes.sample;

public class TryCatchSamples {
	static void myMethod(int n) throws Exception
	{
		try{
			switch(n){
			case 1: System.out.println("1st case");
			return;
			case 3: System.out.println("3rd case");
			throw new Exception("3");
			case 4: System.out.println("4th case");
			throw new Exception("4");
			case 5: System.out.println("5th case");
			throw new RuntimeException("5");
			case 2: System.out.println("2nd case");
			case 6: System.out.println("6th case");
			throw new ArithmeticException("6");
			}
		}catch (ArithmeticException e){
			 System.out.println("arithmetic Exception: ");
			 System.out.println(e.getMessage());
		}
		catch (RuntimeException e){
			 System.out.println("runtime Exception caught: ");
			 System.out.println(e.getMessage());
				throw new SampleException();
		}
		catch (Exception e){
			 System.out.println("Runtime Exception: ");
			 System.out.println(e.getMessage());
			 throw new Exception();
		}finally{
			System.out.println("\n try-block entered");
		}
	}

}
